package Hot100;

import LinkedList.ListNode;

public class 环形链表 {
    public boolean hasCycle(ListNode head) {
        if (head == null) return false;
        ListNode slow = head;
        ListNode fast = head;
        while (fast != null) {
            slow = slow.next;
            if (fast.next != null) fast = fast.next.next;
            else return false;
            if (slow == fast) return true;
        }
        return false;
    }
}
